home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / doslynx / src / turlvi28.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  3.5 KB  |  124 lines

  1. //    Copyright (c) 1994, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        TURLView
  4. //    Include File:    turlview.h
  5. //    Purpose:    Provide a view for any URL.
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //    Revision History:
  8. //        04-07-94    created
  9. #define Uses_TDialog
  10. #define Uses_TInputLine
  11. #define Uses_TLabel
  12. #define Uses_TButton
  13. #define Uses_TProgram
  14. #define Uses_TDeskTop
  15. #include"turlview.h"
  16. #include"globals.h"
  17. #include<string.h>
  18.  
  19. void TURLView::addToHotList()    {
  20. //    Purpose:    Add the currently displayed view to the hotlist file.
  21. //    Arguments:    void
  22. //    Return Value:    void
  23. //    Remarks/Portability/Dependencies/Restrictions:
  24. //        If the hotlistfile is not specified, nothing will happen.
  25. //        If the hotlistfile does not exist, an attempt to create one
  26. //            will be made.
  27. //        If the hotlistfile exists, the current view's URL will be
  28. //            appended to it.
  29. //    Revision History:
  30. //        04-07-94    created
  31.  
  32.     //    See if we have a hotlist file.
  33.     if(::cp_HotList == NULL)    {
  34.         doslynxmessage("hotlistfile not specified in the "
  35.             "configuration file.");
  36.         return;
  37.     }
  38.  
  39.     //    Attempt to open to append.
  40.     auto fstream *fsp_hotlist = new fstream(cp_HotList, ios::out |
  41.         ios::app);
  42.     if(fsp_hotlist == NULL)    {
  43.         doslynxmessage("Unable to open hotlistfile specified in "
  44.             "the configuration file.");
  45.         return;
  46.     }
  47.  
  48.     //    Get the user's name for the anchor to add to the hotlist.
  49.     //    General use rectangle.
  50.     auto TRect TR(0, 0, 50, 7);
  51.  
  52.     //    Create a dialog that asks for the title.
  53.     TDialog *TDp_title = new TDialog(TR, "Add to Hotlist");
  54.     if(TDp_title == NULL)    {
  55.         doslynxmessage("Unable to create title dialog.");
  56.         return;
  57.     }
  58.  
  59.     //    Set some dialog options.
  60.     TDp_title->options |= ofCentered;
  61.  
  62.     //      Make the input line to enter the title.
  63.     TR = TRect(6, 2, 44, 3);
  64.     TInputLine *TILp_title = new TInputLine(TR, usi_TILURLSize - 1);
  65.     if(getTitle() != NULL)    {
  66.         TILp_title->setData((void *)getTitle());
  67.     }
  68.     TDp_title->insert(TILp_title);
  69.  
  70.  
  71.     //    Make the input line's label.
  72.     TR = TRect(5, 1, 44, 2);
  73.     TLabel *TLp_prompt = new TLabel(TR, "~E~nter a name to remember "
  74.         "the URL by", TILp_title);
  75.     TDp_title->insert(TLp_prompt);
  76.  
  77.     //    Insert the Ok and Cancel buttons.
  78.     auto TButton *TBp_button;
  79.     TR = TRect(9, 4, 21, 6);
  80.     TBp_button = new TButton(TR, "~O~K", cmOK, bfDefault);
  81.     TDp_title->insert(TBp_button);
  82.     TR = TRect(24, 4, 36, 6);
  83.     TBp_button = new TButton(TR, "~C~ancel", cmCancel, bfNormal);
  84.     TDp_title->insert(TBp_button);
  85.  
  86.     //    Stay in the device name field.
  87.     TDp_title->selectNext(False);
  88.  
  89.     //    Draw the dialog.
  90.     TDp_title->drawView();
  91.  
  92.     //    Execute the dialog.
  93.     if(TProgram::deskTop->execView(TDp_title) != cmCancel)    {
  94.         //    User didn't cancel, save what we got as the device
  95.         //    name.
  96.         auto char ca_buffer[usi_TILURLSize];
  97.         TILp_title->getData(ca_buffer);
  98.  
  99.         //    Output a new line in the hotlist file.
  100.         fsp_hotlist->write("\n<BR>\n", 6);
  101.  
  102.         //    Write out the anchor.
  103.         fsp_hotlist->write("<A HREF=\"", 9);
  104.         fsp_hotlist->write(getURL(), strlen(getURL()));
  105.         fsp_hotlist->write("\">", 2);
  106.         fsp_hotlist->write(ca_buffer, strlen(ca_buffer));
  107.         fsp_hotlist->write("</A>", 4);
  108.  
  109.  
  110.         //    Give a message telling the user that the change
  111.         //    may not be immediate.
  112.         doslynxmessage("If the Hot List is being viewed or has been "
  113.             "recently");
  114.         doslynxmessage("you may have to exit DosLynx before changes "
  115.             "take effect.");
  116.     }
  117.  
  118.     //    Done with dialog.
  119.     destroy(TDp_title);
  120.  
  121.     //    Done with the file.
  122.     fsp_hotlist->close();
  123.     delete(fsp_hotlist);
  124. }